package com.neuedu.his.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neuedu.his.po.User;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT * FROM `user` WHERE UserName = #{userName}")
    User selectByUserName(String userName);

    @Select({
            "<script>",
            "SELECT * FROM `user`",
            "WHERE DelMark = 1",
            "<if test='realName != null and realName != \"\"'>",
            "  AND RealName LIKE CONCAT('%', #{realName}, '%')",
            "</if>",
            "</script>"
    })
    List<User> selectByRealName(String realName);

    @Update("UPDATE `user` SET DelMark = 0 WHERE ID = #{id}")
    int deleteUserById(Integer id);

    @Update("UPDATE `user` SET UserName = #{userName}, Password = #{password}, RealName = #{realName}, UseType = #{useType}, DocTitleID = #{docTitleID}, IsScheduling = #{isScheduling}, DeptID = #{deptID}, RegistLeID = #{registLeID}, DelMark = #{delMark} WHERE ID = #{id}")
    int updateUser(User user);


}